package 集合;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < n + m; i++) {
            set.add(in.nextInt());
        }
        for (int a : set) {
            System.out.print(a + " ");
        }
    }
}
